﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:p="clr-namespace:Lithnet.Acma.Presentation"
                    xmlns:a="clr-namespace:Lithnet.Acma;assembly=Lithnet.Acma"
                    xmlns:fim="clr-namespace:Microsoft.MetadirectoryServices;assembly=Microsoft.MetadirectoryServicesEx"
                    xmlns:core="clr-namespace:Lithnet.Common.Presentation;assembly=Lithnet.Common.Presentation"
                    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase">

    <DataTemplate  DataType="{x:Type p:AcmaSchemaShadowObjectLinksViewModel}">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Grid.Resources>
                <CollectionViewSource Source="{Binding Path=.,Mode=OneWay}"
                                      x:Key="sortedAttributes">
                    <CollectionViewSource.SortDescriptions>
                        <scm:SortDescription PropertyName="Name" />
                    </CollectionViewSource.SortDescriptions>
                </CollectionViewSource>

            </Grid.Resources>

            <ListView Grid.Row="0"
                      Margin="6"
                      ScrollViewer.VerticalScrollBarVisibility="Auto"
                      ItemsSource="{Binding Source={StaticResource sortedAttributes}}"
                      Name="ListView">
                <ListView.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Add link..."
                                  Command="{Binding Commands.AddLink}" />
                    </ContextMenu>
                </ListView.ContextMenu>
                
                <ListView.Resources>
                    <ContextMenu x:Key="ItemContextMenu">
                        <MenuItem Header="Add link..."
                                  Command="{Binding Commands.AddLink}" />
                        <MenuItem Header="Delete link..."
                                  Command="{Binding Commands.DeleteLink}" />
                    </ContextMenu>
                </ListView.Resources>
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="ContextMenu"
                                Value="{StaticResource ItemContextMenu}" />
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.View>
                    <GridView>
                        <GridViewColumn Width="Auto">
                            <GridViewColumnHeader Content="Link name" />
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="{Binding Path=DisplayIcon}" />
                                        <TextBlock Text="{Binding Path=Name}" />
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Width="Auto">
                            <GridViewColumnHeader Content="Reference attribute" />
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TextBlock Text="{Binding Path=ReferenceAttributeName}" />
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Width="Auto">
                            <GridViewColumnHeader Content="Provisioning control attribute" />
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TextBlock Text="{Binding Path=ProvisioningAttributeName}" />
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Width="Auto">
                            <GridViewColumnHeader Content="Parent object class" />
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <TextBlock Text="{Binding Path=ParentObjectClassName}" />
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                       
                    </GridView>
                </ListView.View>
            </ListView>

        </Grid>
    </DataTemplate>
</ResourceDictionary>